package io.xxx.omni.oss.custom

import com.google.gson.JsonObject
import io.xxx.omni.oss.common.toJsonString
import io.xxx.omni.oss.domain.Document
import io.xxx.omni.oss.domain.DocumentType
import java.time.LocalDateTime

@Suppress("unused")
class TxhjRefundSynchronizer : TxhjSynchronizer() {

    override val documentType = DocumentType.REFUND

    override val path = "/aftersale/list"

    override fun buildDocuments(context: Context, response: JsonObject): List<Document> {
        return response.getAsJsonArray("orderList")
            .map {
                it as JsonObject
                val now = LocalDateTime.now()
                Document(
                    it["orderId"].asString,
                    it["afterSaleOrderId"].asString,
                    it["status"].asString,
                    it.toJsonString(),
                    now,
                    now,
                )
            }
    }

    override fun buildRequest(context: Context, pageNo: Int): Map<String, Any> {
        TODO("Not yet implemented")
    }
}